package com.yycwxt.modules.admin.dpyy;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yycwxt.domain.Dpyy;
import com.yycwxt.domain.Return;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
public interface DpyyMapper extends BaseMapper<Dpyy> {

    @Select("""
            SELECT  account_date '账期'
                   ,shop_name '店铺名称'
                   ,SUM(CASE	WHEN subject_code = '1003-01-001' THEN cost END)'保证金理赔'
                   ,SUM(CASE	WHEN subject_code = '1003-01-002' THEN cost END)'天猫返回点积分'
                   ,SUM(CASE	WHEN subject_code = '1003-01-003' THEN cost END)'平台佣金'
                   ,SUM(CASE	WHEN subject_code = '1003-01-004' THEN cost END)'支付宝服务费'
                   ,SUM(CASE	WHEN subject_code = '1003-01-005' THEN cost END)'活动服务费'
                   ,SUM(CASE	WHEN subject_code = '1003-01-025' THEN cost END)'直播间站外推广'
                   ,SUM(CASE	WHEN subject_code = '1003-01-006' THEN cost END)'天猫360质保保费'
                   ,SUM(CASE	WHEN subject_code = '1003-01-007' THEN cost END)'公益宝贝捐款'
                   ,SUM(CASE	WHEN subject_code = '1003-01-008' THEN cost END)'提前收款服务费'
                   ,SUM(CASE	WHEN subject_code = '1003-01-009' THEN cost END)'运费保险'
                   ,SUM(CASE	WHEN subject_code = '1003-01-010' THEN cost END)'其他保险'
                   ,SUM(CASE	WHEN subject_code = '1003-01-011' THEN cost END)'软件服务费'
                   ,SUM(CASE	WHEN subject_code = '1003-01-012' THEN cost END)'花呗/信用卡服务费'
                   ,SUM(CASE	WHEN subject_code = '1003-01-013' THEN cost END)'评价服务费'
                   ,SUM(CASE	WHEN subject_code = '1003-01-014' THEN cost END)'店铺保证金（新店）'
                   ,SUM(CASE	WHEN subject_code = '1003-01-018' THEN cost END)'平台服务费（京东）'
                   ,SUM(CASE	WHEN subject_code = '1003-01-026' THEN cost END)'淘宝客佣金'
                   ,SUM(CASE	WHEN subject_code = '1003-01-027' THEN cost END)'品牌新享'
                   ,SUM(CASE	WHEN subject_code = '1003-01-028' THEN cost END)'代销分账'
                   ,SUM(CASE	WHEN subject_code = '1003-01-019' THEN cost END)'多多进宝'
                   ,SUM(CASE	WHEN subject_code = '1003-01-020' THEN cost END)'技术服务费'
                   ,SUM(CASE	WHEN subject_code = '1003-01-029' THEN cost END)'扣款-物流未兑现'
                   ,SUM(CASE	WHEN subject_code = '1003-01-030' THEN cost END)'拼多多-其他-小额补偿'
                   ,SUM(CASE	WHEN subject_code = '1003-01-031' THEN cost END)'拼多多-其他服务（短信服务）'
                   ,SUM(CASE	WHEN subject_code = '1003-01-015' THEN cost END)'随单送的京豆'
                   ,SUM(CASE	WHEN subject_code = '1003-01-016' THEN cost END)'京桃客扣款'
                   ,SUM(CASE	WHEN subject_code = '1003-01-017' THEN cost END)'直赔退款代扣'
                   ,SUM(CASE	WHEN subject_code = '1003-01-032' THEN cost END)'仓储费，收派费（京东）'
                   ,SUM(cost * subject_direction) '汇总'
                   FROM core_flows
                   WHERE (subject_code = '1003-01-001'
                     or subject_code = '1003-01-002'
                     or subject_code = '1003-01-003'
                     or subject_code = '1003-01-004'
                     or subject_code = '1003-01-005'
                     or subject_code = '1003-01-006'
                     or subject_code = '1003-01-007'
                     or subject_code = '1003-01-008'
                     or subject_code = '1003-01-009'
                     or subject_code = '1003-01-010'
                     or subject_code = '1003-01-011'
                     or subject_code = '1003-01-012'
                     or subject_code = '1003-01-013'
                     or subject_code = '1003-01-014'
                     or subject_code = '1003-01-015'
                     or subject_code = '1003-01-016'
                     or subject_code = '1003-01-017'
                     or subject_code = '1003-01-018'
                     or subject_code = '1003-01-019'
                     or subject_code = '1003-01-020'
                     or subject_code = '1003-01-025'
                     or subject_code = '1003-01-026'
                     or subject_code = '1003-01-027'
                     or subject_code = '1003-01-028'
                     or subject_code = '1003-01-029'
                     or subject_code = '1003-01-030'
                     or subject_code = '1003-01-031'
                     or subject_code = '1003-01-032')
                   and account_date = #{account_date}
                   GROUP BY account_date,shop_name
            """)
    List<Map<String, Object>> getdpyy(int zq);

    // 下载源文件
    @Select("select url from imp_files where remark like '%店铺运营%'")
    List<String> getDpyyUrl();
}
